package cn.tedu.csmall.stock.webapi.quartz;

import cn.tedu.csmall.stock.webapi.mapper.StockMapper;
import cn.tedu.csmall.stock.webapi.utils.RedisBloomUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;

public class QuartzJob implements Job {
    @Autowired
    private RedisBloomUtils redisBloomUtils;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.out.println("-------------------------"+LocalDateTime.now());

        // 先将要添加到布隆过滤器的元素保存在一个数组中
        String[] colors = {"red","origin","yellow","green","blue","pink"};
        // 将上面的集合中的元素批量新增到布隆过滤器中
        redisBloomUtils.bfmadd("color",colors);
        // 定义一个要判断是否在集合中的元素
        String elm = "black";
        System.out.println("布隆过滤器判断"+elm+"是否在集合中:"+redisBloomUtils.bfexists("color",elm));
    }
}
